"""
__author__ = '霍格沃兹测试开发学社'
__desc__ = '更多测试开发技术探讨，请访问：https://ceshiren.com/t/topic/15860'
"""
from run import db
from sqlalchemy import *

# 用户表
class User(db.Model):
    __tablename__ = "user"
    # 用户ID，用户的唯一标识
    id = db.Column(Integer, autoincrement=True, primary_key=True)
    # 用户名
    username = db.Column(String(45),nullable=False,unique=True)
    # 密码
    password = db.Column(String(128),nullable=False)
    # 激活状态
    active = db.Column(Boolean,default=True,nullable=False)

    def __init__(self, username, password, active=True):
        self.username = username
        self.password = password
        self.active = active

    def __repr__(self):
        return '<User %r>' % self.username

    def as_dict(self):
        return {"id": self.id, "username": self.username, "password": self.password, "active": self.active}


if __name__ == '__main__':
    db.create_all()